/*
 * DTOFinHandshake.cpp
 *
 *  Created on: Nov 5, 2011
 *      Author: gonzalo
 */

#include "DTOFinHandshake.h"
#include "Constantes.h"

DTOFinHandshake::DTOFinHandshake(unsigned int listenPort,unsigned int broadcastPort,int width,int height) : DTO(FIN_HANDSHAKE,SERVER_OWN) {
	this->listenPort = listenPort;
	this->broadcastPort = broadcastPort;
	this->width = width;
	this->height = height;
}

DTOFinHandshake::~DTOFinHandshake() {
}


DTOFinHandshake::DTOFinHandshake(std::string& aDeserealizar,std::string owner) : DTO(FIN_HANDSHAKE,owner){
	deserializar(aDeserealizar);
}

std::string DTOFinHandshake::serializar(){
	std::stringstream retorno;

	retorno << UtilString::TOlenghtStringStringValue(listenPort);
	retorno << UtilString::TOlenghtStringStringValue(broadcastPort);
	retorno << UtilString::TOlenghtStringStringValue(width);
	retorno << UtilString::TOlenghtStringStringValue(height);

	return retorno.str();
}

void DTOFinHandshake::deserializar(std::string& string){
	listenPort = UtilString::stringToUnsignedInt(UtilString::FROMlenghtStringStringValue(string));
	broadcastPort = UtilString::stringToUnsignedInt(UtilString::FROMlenghtStringStringValue(string));
	width = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	height = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
}


unsigned int DTOFinHandshake::getListenPort() const{
	return listenPort;
}

unsigned int DTOFinHandshake::getBroadcastPort() const{
	return broadcastPort;
}

int DTOFinHandshake::getHeight() const
{
    return height;
}

int DTOFinHandshake::getWidth() const
{
    return width;
}


